package cn.maihe.elg.operation.supports.electronicseal.anne.bean.annesign.base;

import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.JsonUtils;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.ValidateException;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.ValidateUtils;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.Validateable;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;

public class ObjectInfo implements Validateable, Serializable {

    @Override
    public boolean validate() throws ValidateException {
        ValidateUtils.validate(this);
        return true;
    }

    @Override
    public boolean validateOnce() throws ValidateException {
        ValidateUtils.validateOnce(this);
        return true;
    }

    public String toJson() {
        return JsonUtils.toJson(this);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

}
